package com.he.validator;

import com.he.domain.dto.LinkDTO;
import com.he.enums.LinkEnum;
import com.he.validator.groups.*;
import org.hibernate.validator.spi.group.DefaultGroupSequenceProvider;
import java.util.ArrayList;
import java.util.List;


/**
 * @author He
 * @version 1.0
 * @Date 2023/10/22 8:24
 * @Desc
 */
public class LinkProvider implements DefaultGroupSequenceProvider<LinkDTO> {
    @Override
    public List<Class<?>> getValidationGroups(LinkDTO linkDTO) {
        List<Class<?>> defaultGroupSequence = new ArrayList<>();
        defaultGroupSequence.add(LinkDTO.class);
        if (linkDTO != null) {
            //如果是友链类型
            if (linkDTO.getType().equals(LinkEnum.FRIEND.getType())) {
                defaultGroupSequence.add(FriendLink.class);
            }
            return defaultGroupSequence;
        }
        return defaultGroupSequence;
    }
}
